package ynu.edu.model.entity;

import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * 汉字生成记录实体类
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("hanzi_generation")
public class HanziGeneration implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 主键ID
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    /**
     * 汉字字符
     */
    @TableField("chinese_char")
    private String chineseChar;

    /**
     * 生成步数
     */
    @TableField("steps")
    private Integer steps;

    /**
     * 生成状态：processing-生成中, success-成功, failed-失败
     */
    @TableField("status")
    private String status;

    /**
     * OSS存储的图片URL
     */
    @TableField("oss_url")
    private String ossUrl;

    /**
     * 本地临时文件路径
     */
    @TableField("local_path")
    private String localPath;

    /**
     * 生成耗时（毫秒）
     */
    @TableField("generation_time")
    private Long generationTime;

    /**
     * 错误信息
     */
    @TableField("error_message")
    private String errorMessage;

    /**
     * 请求ID，用于追踪
     */
    @TableField("request_id")
    private String requestId;

    /**
     * 创建时间
     */
    @TableField(value = "create_time", fill = FieldFill.INSERT)
    private LocalDateTime createTime;

    /**
     * 更新时间
     */
    @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updateTime;

    /**
     * 逻辑删除标志：0-未删除，1-已删除
     */
    @TableLogic
    @TableField("deleted")
    private Integer deleted;

    /**
     * 状态枚举
     */
    public enum Status {
        PROCESSING("processing", "生成中"),
        SUCCESS("success", "成功"),
        FAILED("failed", "失败");

        private final String code;
        private final String description;

        Status(String code, String description) {
            this.code = code;
            this.description = description;
        }

        public String getCode() {
            return code;
        }

        public String getDescription() {
            return description;
        }
    }
} 